package alogrithm;

/**
 * @author lbw
 * @version 1.0
 * @date 2021/10/16 15:58
 */
public class BigNumberPlus {
    public String solve(String s, String t) {
        // write code here
        StringBuilder sb = new StringBuilder();
        int m = s.length() - 1;
        int n = t.length() - 1;
        int carry = 0;
        while (m >= 0 || n >= 0) {
            int n1 = m >= 0 ? s.charAt(m) - '0' : 0;
            int n2 = m >= 0 ? t.charAt(n) - '0' : 0;
            int sum = n1 + n2 + carry;
            sb.append(sum % 10);
            carry = sum / 10;
            m--;
            n--;
        }
        if (carry > 0) {
            sb.append(carry);
        }
        return sb.reverse().toString();
    }
}
